package com.ruibang.glass.produce.controller.jjs;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruibang.glass.frequencycontrol.annotation.FrequencyControl;
import com.ruibang.glass.produce.constant.Constants;
import com.ruibang.glass.produce.domain.req.ColdCleanRoomRecordReq;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruibang.glass.produce.service.ProduceColdCleanRoomRecordService;
import com.ruibang.glass.produce.entity.ProduceColdCleanRoomRecord;

import javax.servlet.http.HttpServletResponse;


/**
 * <p>
 * 生产-洁净室-冷端洁净室环境记录 前端控制器
 * </p>
 *
 * @author 宋锦康
 * @since 2024-03-11
 */
@RestController

@RequestMapping("/api/glass/produce/jjs/coldCleanRoomRecord")
@Api(value = "生产-洁净室-冷端洁净室环境记录控制器", tags = {"生产-洁净室-冷端洁净室环境记录接口"})
public class ProduceColdCleanRoomRecordController {

    @Autowired
    private ProduceColdCleanRoomRecordService produceColdCleanRoomRecordService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取生产-洁净室-冷端洁净室环境记录", notes = "获取生产-洁净室-冷端洁净室环境记录")
    public ResultBody getById(@PathVariable(value = "id") String id) {
        return ResultBody.success(produceColdCleanRoomRecordService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增生产-洁净室-冷端洁净室环境记录", notes = "新增生产-洁净室-冷端洁净室环境记录")
    public ResultBody save(@RequestBody ProduceColdCleanRoomRecord produceColdCleanRoomRecord) {
        produceColdCleanRoomRecord.setIsDelete(Constants.ZERO_STR);
        produceColdCleanRoomRecordService.save(produceColdCleanRoomRecord);
        return ResultBody.success();
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "通过ID删除生产-洁净室-冷端洁净室环境记录", notes = "通过ID删除生产-洁净室-冷端洁净室环境记录")
    public ResultBody delete(@PathVariable(value = "id") String id) {
        produceColdCleanRoomRecordService.delete(id);
        return ResultBody.success();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改生产-洁净室-冷端洁净室环境记录", notes = "修改生产-洁净室-冷端洁净室环境记录")
    public ResultBody updateById(@RequestBody ProduceColdCleanRoomRecord produceColdCleanRoomRecord) {
        produceColdCleanRoomRecordService.updateById(produceColdCleanRoomRecord);
        return ResultBody.success();
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询生产-洁净室-冷端洁净室环境记录", notes = "分页列表查询生产-洁净室-冷端洁净室环境记录")
    public ResultBody<IPage<ProduceColdCleanRoomRecord>> pageQuery(@RequestBody ColdCleanRoomRecordReq coldCleanRoomRecordReq) {
        return ResultBody.success(produceColdCleanRoomRecordService.pageQuery(coldCleanRoomRecordReq));
    }

    @PostMapping("/export")
    @ApiOperation(value = "数据导出")
    @FrequencyControl(time = 15, count = 2, target = FrequencyControl.Target.IP)
    @FrequencyControl(time = 30, count = 4, target = FrequencyControl.Target.IP)
    public void export(@RequestBody ColdCleanRoomRecordReq coldCleanRoomRecordReq, HttpServletResponse response) {
        produceColdCleanRoomRecordService.export(coldCleanRoomRecordReq, response);
    }
}
